#!/bin/bash

# 进入项目根目录
cd "$(dirname $0)"

# 安装依赖
# TODO: 根据不同的版本和不同的系统来生成安装包
SDK="build-essential gawk gcc-multilib flex git gettext libncurses5-dev libssl-dev python3-distutils zlib1g-dev"
# TODO: 仅在ubuntu20.04生效，22.04会报错
BUILDER="build-essential libncurses5-dev libncursesw5-dev zlib1g-dev gawk git gettext libssl-dev xsltproc rsync wget unzip python"
MENU_CONFIG="python3 python3-venv"
PACKAGES="${BUILDER} ${MENU_CONFIG}"
apt-get install -y ${PACKAGES}
if [ $? -ne 0 ]; then
    apt-get update && apt-get install -y ${PACKAGES}
    if [ $? -ne 0 ]; then
        echo -e "\033[31m无法安装依赖。\033[0m"
        exit 1
    fi
fi

# 安装虚拟环境
python3 -m venv .venv
.venv/bin/pip3 install requests beautifulsoup4 rich
